package oa.hleast.xswl.mapper.activity;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import oa.hleast.xswl.pojo.domain.activity.CmsActivityCalendar;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface CmsActivityCalendarMapper extends BaseMapper<CmsActivityCalendar> {

    @Select("select c.* from (" +
            "select * from cms_activity_calendar where activity_start_date <= #{afterLongDate} and activity_end_date >= #{nowLongDate}) c " +
            "left join cms_activity_manager_user  u on c.activity_id = u.activity_id where u.manager_user_id = #{managerUserId};")
    List<CmsActivityCalendar> findCalenderByManagerUserAndNowDate(Long managerUserId, Date afterLongDate, Date nowLongDate);

    @Select("select count(id) from cms_activity_calendar where activity_id = #{scenesId} and  activity_end_date > #{nowDate}")
    int isActivityEnd(Long scenesId, Date nowDate);
}